/**
 *  @file: UiTask.h
 *  @author: nwz
 *  @brief: 
 *  @date: 2024年8月6日
 * 
 */

#pragma once

#include <all_header.h>

namespace task {
/*
 *
 */
class UiTask {
public:
	UiTask(LcdTask& lcdTask);
	virtual ~UiTask();

	static void run(UiTask* task){
		task->init();
		task->run_();
	}

	void pubKeyEvent(void* event);
	void pubPageChange();
private:
	enum class QueueId:uint8_t{
		KEY = 0,PAGE_CHANGE, HOME_PAGE_UPDATE,
	};
	typedef struct{
		uint32_t id;
		uint8_t data[8];
	}que_data_t;
	QueueHandle_t que;
	void init();
	void basicInit();
	void uiInit();
	void run_();
	PageManager pageManager;
	LcdTask& lcdTask;

	uint32_t calculateSleepTicks();
	void pub(QueueId id,void* data = nullptr, uint8_t size = 0);
	void processKey(void* event);
	void processPageChange(PageId id);

	TimerHandle_t homePageTimer ;
	static void pubUpdateHomePageUI(TimerHandle_t timer);
	void updateHomePage();
};

} /* namespace task */
